package com.imay.live.adapter;

import android.support.annotation.Nullable;
import android.widget.ImageView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.imay.live.R;
import com.imay.live.model.MusicModel;
import com.imay.live.utils.AnimationUtil;
import com.imay.live.view.refresh.RefreshView;

import java.util.List;

/**
 * Created by nick on 2017/7/24.
 * 音乐
 */

public class MusicAdapter extends BaseQuickAdapter<MusicModel, BaseViewHolder> {

    public MusicAdapter(@Nullable List<MusicModel> data) {
        super( R.layout.item_music_select,data);
    }

    @Override
    protected void convert(BaseViewHolder helper, MusicModel item) {
        helper.setText(R.id.tv_name_music_select,item.getName());
        helper.setText(R.id.tv_lable_music_select,item.getMusicLabel());
        ImageView imageView = helper.getView(R.id.iv_play_music_select);
        RefreshView refreshView = helper.getView(R.id.rv_loading_music_select);
        switch (item.getStatu()){
            case MusicModel.STATU_NO_DOWNLOAD:
                helper.setTextColor(R.id.tv_name_music_select,mContext.getResources().getColor(R.color.text_75));
                helper.setVisible(R.id.iv_play_music_select,false);
                helper.setVisible(R.id.iv_dowmload_music_select,true);
                helper.setVisible(R.id.rv_loading_music_select,false);
                break;
            case MusicModel.STATU_DOWNLOADING:
                helper.setTextColor(R.id.tv_name_music_select,mContext.getResources().getColor(R.color.text_bc));
                helper.setVisible(R.id.iv_play_music_select,false);
                helper.setVisible(R.id.iv_dowmload_music_select,false);
                helper.setVisible(R.id.rv_loading_music_select,true);
                refreshView.startAnim(30,30);
                break;
            case MusicModel.STATU_DOWNLOADED:
                helper.setTextColor(R.id.tv_name_music_select,mContext.getResources().getColor(R.color.text_ff));
                helper.setVisible(R.id.iv_play_music_select,false);
                helper.setVisible(R.id.iv_dowmload_music_select,false);
                helper.setVisible(R.id.rv_loading_music_select,false);
                break;
            case  MusicModel.STATU_SELECTED:
                helper.setTextColor(R.id.tv_name_music_select,mContext.getResources().getColor(R.color.color_ff));
                helper.setVisible(R.id.iv_play_music_select,item.isPlaying());
                helper.setVisible(R.id.iv_dowmload_music_select,false);
                helper.setVisible(R.id.rv_loading_music_select,false);
                if (item.isPlaying()) {
                    AnimationUtil.rotationInAnimation(imageView, 0f, 359f);
                }
                break;
        }

    }
}
